<template>
  <div class="content">
    <!-- 头部 -->
    <div class="header">
      <van-icon name="arrow-left" @click="goBack" />
      <span>地址列表</span>
    </div>
    <van-address-list
      v-model="chosenAddressId"
      :list="list"
      default-tag-text="默认"
      @add="onAdd"
      @edit="onEdit"
    />
  </div>
</template>

<script>
import { Toast } from "vant";

export default {
  name: "MyAddAddress",
  data() {
    return {
      chosenAddressId: "1",
      list: [
        {
          id: "2",
          name: "李四",
          tel: "1310000000",
          address: "浙江省杭州市拱墅区莫干山路 50 号",
        },
      ],
    };
  },
  methods: {
    goBack() {
      this.$router.back();
    },
    onAdd() {
      Toast("新增地址");
      this.$router.push("/MyAddAddress");
    },
    onEdit(item, index) {
      Toast("编辑地址:" + index);
    },
  },
};
</script>

<style scoped>
.header {
  height: 3.5rem;
  text-align: center;
  font-size: 1.3rem;
  line-height: 3.5rem;
  border-bottom: 2px solid gray;
}
.van-icon {
  float: left;
  padding-left: 10px;
  line-height: 3.5rem;
  color: rgb(24, 24, 64);
}
</style>